﻿using System.Collections.Generic;
using System.Threading.Tasks;
using TiaoTiaoCode.AutoUpdate.Common.Dtos;
using TiaoTiaoCode.AutoUpdate.Common.Requests;

namespace TiaoTiaoCode.AutoUpdate.ServiceCore.IServices
{
    /// <summary>
    /// 主程序服务
    /// </summary>
    public interface IMainProgramVersionService
    {
        /// <summary>
        /// 创建更新信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<List<MainProgramView>> CreateMainProgramInfo(MainProgramCreateDto dto);

        /// <summary>
        /// 更新程序信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<List<MainProgramView>> UpdateMainProgramInfo(MainProgramUpdateDto dto);

        /// <summary>
        /// 根据主程序名，扫描文件
        /// </summary>
        /// <param name="mainProgramName"></param>
        /// <returns></returns>
        Task<List<MainProgramFileDetailView>> ScanMainProgramFiles(string mainProgramName);

        /// <summary>
        /// 获取更新文件列表
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        Task<List<ProgrameFileDetailView>> ProgramFileDetails(ProgramUpdateInfoRequest req);

        /// <summary>
        /// 检测当前程序是否有更新版本
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        Task<UpgradeInfoDto> CheckHasUpgrade(ProgramUpdateInfoRequest req);

        /// <summary>
        /// 获取应用程序列表
        /// 就是查询 版本信息为0.0.0.0的，为系统默认的增加自动更新应用程序时的信息
        /// </summary>
        /// <returns></returns>
        Task<List<MainProgramView>> MainProgramAppList();

        /// <summary>
        /// 发布程序版本
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<List<MainProgramView>> PublishProgram(List<MainProgramView> dto);

        /// <summary>
        /// 查询版本信息
        /// </summary>
        /// <returns></returns>
        Task<List<MainProgramView>> QueryVersion(string? programName);

        /// <summary>
        /// 升级包更新服务器程序
        /// </summary>
        /// <param name="programName"></param>
        /// <param name="fileTempName"></param>
        /// <returns></returns>
        /// <exception cref="CustomException"></exception>
        Task UploadZipFile(string programName, string fileTempName);
    }
}
